package com.sunlands.qdcy.tongzhuo.model;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import java.util.Date;

/**
 * @author mengxc
 * @date 2019/5/3016:39
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@Entity(name = "tz_user_diary_forward")
@JsonSerialize
@DynamicUpdate
@DynamicInsert
@ApiModel(value = "日记转发信息")
public class UserDiaryForwardDO {

    @Id
    @GeneratedValue
    @ApiModelProperty(value = "点赞id")
    private Long id;

    @ApiModelProperty(value = "对象id，根据type:type=1日记id,type=3回复id")
    private Long targetId;

    @ApiModelProperty(value = "类型：1-日记，3-回复")
    private Integer type;

    @ApiModelProperty(value = "转发用户id")
    private Long fromUserId;

    @ApiModelProperty(value = "被转发人id，对应targetId内容的发布者id")
    private Long targetUserId;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createTime;

    @ApiModelProperty(value = "转发位置：1-站内，2-站外微信，3-我的日记")
    private Integer station;

    @ApiModelProperty(value = "当转发到我的日记时使用，存放转发人的内容")
    private String forwardMessage;


    public enum ForwardType {
        /**
         * 转发日记/回复
         */
        DIARY(1, "日记"),
        //        COMMENT(2, "评论"),
        REPLY(3, "回复"),;

        Integer code;
        String desc;

        ForwardType(Integer code, String desc) {
            this.code = code;
            this.desc = desc;
        }

        public static UserDiaryForwardDO.ForwardType create(Integer code) {
            if (null == code) {
                return null;
            }
            for (UserDiaryForwardDO.ForwardType field : UserDiaryForwardDO.ForwardType.values()) {
                if (code.intValue() == field.getCode()) {
                    return field;
                }
            }
            return null;
        }

        public Integer getCode() {
            return code;
        }

        public String getDesc() {
            return desc;
        }

    }


    public enum StationType{
        /**
         * 转发渠道
         */
        STATION_INNER_COMMON(1 , "站内-转发到群"),
        STATION_OUTER_WEIXIN(2, "微信"),
        STATION_INNER_MINE(3, "转发到我的");

        Integer code;
        String desc;

        StationType(Integer code, String desc) {
            this.code = code;
            this.desc = desc;
        }

        public Integer getCode() {
            return code;
        }

        public void setCode(Integer code) {
            this.code = code;
        }

        public String getDesc() {
            return desc;
        }

        public void setDesc(String desc) {
            this.desc = desc;
        }
    }
}
